package com.videoshare.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.*;

import com.sapientia.user.UserConstants;
import com.sapientia.user.UserLoginForm;

public class AdminMainAction extends Action
{
	
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) throws Exception
	{
		HttpSession session = request.getSession();
        UserLoginForm userForm = (UserLoginForm)session.getAttribute(UserConstants.USER_KEY);
        
        if( (userForm != null) && (userForm.isLoggedIn())&& (userForm.getProfile().equals(UserConstants.USER_ROLE_ADMINISTRATOR)))
        {
        	return mapping.findForward("success");
        }
        else
        {
        	System.out.println("User not logged in or not administrator");
        	
        	return mapping.findForward("notLoggedIn");
        }
        
	}
	
}
